
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<div id="app">
			<h1>使用v-model绑定子组件属性</h1>
			<div>{{title}}</div>
			<title-component v-model:currtitle="title"></title-component>
		</div>
		<script>
			var app = Vue.createApp({
				data() {
					return {
						"title":"aaa"
					}
				}
			});
			app.component("title-component",{
				props:['currtitle'],
				emits:['update:currtitle'],
				template:`
				<p style='background-color:lightblue;'>
					<h2>子组件</h2>
				标题是:
				<input type='text' :value='currtitle' 
					@input='$emit("update:currtitle",$event.target.value)'/>
				</p>`
			});
			var vm = app.mount("#app")
		</script>



	</body>
</html>